package com.supermali.util;

/**
 * @project runner
 * @Date 2021/3/3
 * @Auth yangrui
 * 图片切换速率控制类
 **/
public class ImgChangeRate {

    private long totalTime;

    private int index;

    private int millis;// 默认40毫秒一张图片

    public ImgChangeRate() {
        this.totalTime = 0;
        this.index = 0;
        millis = 60;
    }

    public int changeIndex(long delta){
        totalTime+=delta;
        if(totalTime>=millis){
            index++;
            totalTime=totalTime%millis;
        }
        return index;
    }

    public int getIndex() {
        return index;
    }
}
